<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <canvas width="600px" height="600px">

    </canvas>
    <script>
        const canvas = document.querySelector("canvas");
        
        const ctx = canvas.getContext("2d");
        ctx.moveTo(100,100);
        ctx.lineTo(100,300);
        //设置线条宽度
        ctx.lineWidth = 10;
        // 设置线条颜色 （颜色单词 rgb 渐变等）
        ctx.strokeStyle ="red";
        ctx.stroke();
       

    </script>
</body>
</html>